package com.sigmatrix.h5.config;

import org.springframework.beans.BeansException;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;



@Component
public class SpringContextHelper implements ApplicationListener<ApplicationReadyEvent>, ApplicationContextAware, ApplicationEventPublisherAware {
    public static ApplicationContext context;
    public static ApplicationEventPublisher publisher;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        publisher = applicationEventPublisher;
    }


    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
    
    }
    
    public static boolean isprod(){
    	return context.getEnvironment().acceptsProfiles(ProfileEnum.PROD.name);
    }
}
